package com.ccut.lc.controller;


import com.ccut.lc.model.Order;
import com.ccut.lc.model.QueryVo;
import com.ccut.lc.service.OrderListService;
import com.ccut.lc.utils.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;


@Controller
@RequestMapping("order")
public class OrderController {
	@Resource
	private OrderListService OrderListService;
	@RequestMapping("add")
	public String addOrder(Order Order){
		OrderListService.addOrder(Order);
		return "SCUESS";
	}
	@RequestMapping("list")
	public String selOrderList(QueryVo queryVo, Model model){
		Page<Order> page = OrderListService.selOrderList(queryVo);
		model.addAttribute("page",page);
		return "order/order";
	}
	@RequestMapping("compesatelist")
	public String compesatelist(QueryVo queryVo, Model model){
		Page<Order> page = OrderListService.selOrderList(queryVo);
		model.addAttribute("page",page);
		return "compensate/compensateList";
	}
	@RequestMapping("edit")
	@ResponseBody
	public Order edit(Integer id){
		Order Order = OrderListService.findOrderByID(id);
		return Order;
	}

	@RequestMapping("delete")
	@ResponseBody
	public String delete(Integer id){
		String msg = "1";
		try {
			OrderListService.deleteOrder(id);
			msg = "0";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return msg;
	}
	@RequestMapping("update")
	@ResponseBody
	public String update(Order order){
		String msg = "1";
		try {
			OrderListService.updateOrder(order);
			msg = "0";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return msg;
	}
	@RequestMapping("myTag")
	public String myTage() {
		return "myTag";
	}

}
